<?php
/*
 * [JINYUN!] (C)2001-2099 Jinyunweb.com
 * This is NOT a freeware, use is subject to license terms
 * $Id: 2017-12-13 03:39:35 apple $
*/
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'home';
$return['ischecklogin']=cfc('core')->checklogin('','',true);
$this->model('member')->upmember();
$return['pluginset']['ailogo']=tomedia($return['pluginset']['ailogo']);
$return['basic']=$return['pluginset'];
if($_RQ['op']=='home'){
	$return['demo']=$this->model('agent')->getdemo();
	if($_RQ['id']){
		$return['goods']=pdo_get('jy_aiagent_goodslog',array('id'=>$_RQ['id'],'uniacid'=>$_SESSION['uniacid']));
		$return['post']=pdo_get('jy_aiagent_useragent',array('id'=>$return['goods']['agentid'],'uniacid'=>$_SESSION['uniacid']));
		if(!$return['post']){
			$return['post']=pdo_get('jy_aiagent_useragent',array('mid'=>$_SESSION['uid'],'uniacid'=>$_SESSION['uniacid']));
			pdo_update('jy_aiagent_goodslog',array('agentid'=>$return['post']['id'],'agentapiid'=>$return['post']['apiid']),array('id'=>$_RQ['id'],'uniacid'=>$_SESSION['uniacid']));
		}
		$return['post']['goodsid']=$return['goods']['id'];
		$return['post']['logo']=tomedia($return['post']['logo']);
		$return['post']['desc']=cfc('tools')->substr($return['post']['desc'],0,'218');
	}else{
		exi('请选择设备进入！','error');
	}
	$return['llm_models']=$this->llm_models;
	$return['llm_models2']=array();
	$index=0;
	foreach($return['llm_models'] as $k=>$title){
		if($k==$return['post']['llm_model']){
			$return['post']['llm_model2']=$index;
		}
		$index++;
		$return['llm_models2'][]=array('id'=>$k,'title'=>$title);
	}
	$return['yuyuantypes']=$this->yuyuantypes;
	$return['voices']=array();
	$return['post']['voiceid']=$return['post']['voiceid']?:$return['demo']['voiceid'];
	$return['post']['voicetitle']=pdo_getcolumn('jy_aiagent_voice',array('id'=>$return['post']['voiceid'],'uniacid'=>$_SESSION['uniacid']),'title');
	$return['post']['language']=pdo_getcolumn('jy_aiagent_voice',array('id'=>$return['post']['voiceid'],'uniacid'=>$_SESSION['uniacid']),'language');
	$return['post']['languagetitle']=$this->yuyuantypes[$return['post']['language']];
	$return['post']['llm_modeltitle']=$this->llm_models[$return['post']['llm_model']];
	$return['params']=array('type'=>0,'voicesex'=>0,'yuyuantype'=>0);
	$return['sharedata']=array(
		'title'=>$return['goods']['title'],
		'desc'=>$return['basic']['share_desc'],
		'link'=>custom_url('jy_aiagent/index//fromuser='.$_SESSION['uid'],true),
		'imgUrl'=>$return['post']['logo'],
	);
	set_html('title',$return['goods']['title']);
	exi($return);
}